﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 多态
{
    class SalariedEmployee :Employee 
    {
        private decimal weeklySalary;

        public SalariedEmployee(string first, string last, string num, decimal salary):base(first,last,num)
        {
            WeeklySalary = salary;
        }

        public decimal WeeklySalary
        {
            get
            {
                return weeklySalary;
            }
            set
            {
                weeklySalary = value > 0 ? value : 0;
            }
        }

        public override string ToString()
        {
            return string.Format("{0}\nweekly salary:{1:C}", base.ToString(), WeeklySalary);
        }

        public override decimal Earning()
        {
            return WeeklySalary;
        }
    }//end class SalariedEmployee
}
